from operator import mod
from tkinter.tix import Tree
import markdown
import os
from tools.StringTool import md2html

module_path = '/Users/bsj/Documents/Projects/PHOLP/testFiles/modules'
output_path = module_path + '_html'
os.makedirs(output_path, exist_ok=True)

def multiMarkdown2Html(dir):
    father_path = True
    for dirpath, dirnames, filenames in os.walk(dir):
        #print(dirpath, dirnames, filenames)
        for filename in filenames:
            source_filepath = os.path.join(dirpath, filename)
            target_filepath = os.path.join(dirpath.replace(module_path, output_path), md2html(filename))
            print(target_filepath)
            os.makedirs(dirpath.replace(module_path, output_path), exist_ok=True)
            markdown.markdownFromFile(input=source_filepath, output=target_filepath)

multiMarkdown2Html(module_path)